package com.chat.system.controller;

import com.chat.system.entity.domain.Res;
import com.chat.system.entity.dto.ChatFriendDTO;
import com.chat.system.entity.dto.ChatUserDTO;
import com.chat.system.service.IChatUserRelationshipService;
import com.chat.system.utils.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author czh
 * @since 2023-10-28
 */
@RestController
@RequestMapping("/chatUserRelationship")
public class ChatUserRelationshipController {

    @Autowired
    IChatUserRelationshipService chatUserRelationshipService;

    @GetMapping("getFriendList")
    public Res getFriendList() {
        final String currentUserName = UserUtil.getCurrentUserName();
        List<ChatFriendDTO> list =  chatUserRelationshipService.getFriendList(currentUserName);
        final Res success = Res.success();
        success.put("list",list);
        return success;
    }
}
